home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / b-block1.lha / B_Block_Save.s < prev    next >
Encoding:
Text File  |  1980-01-01  |  4.6 KB  |  117 lines

  1. ; *** BBSave written by Gerson Kurz ***
  2. ;
  3. ; Size : 632 Bytes !!
  4. ;
  5. ; Dieser Befehl liest den Bootblock von df0: ein und speichert ihn in einem
  6. ; beliebigen File ab. Wenn spaeter mal ein Virus den Bootblock zerstoert,
  7. ; kann man den Bootblock mit BBLoad wieder abspeichern...
  8. ; -----------------------------------------------------------------
  9. ; Zuerst suchen wir uns einen Task fuer unser Trackdiskdevice
  10. ; -----------------------------------------------------------------
  11. o:    cmp.b    #1,d0        ; Keine Parameter ?
  12.     bls.l    nofile        ; Ja, Error !
  13.     movem.l    d0-d3/a0-a4,-(sp); Register sichern
  14.     move.l    4,a6        ; Execbase als Basisadr.
  15.     suba.l    a1,a1        ; eigener Task
  16.     jsr    -294(a6)    ; ExecCall FINDTASK
  17.     move.l    d0,readreply+$10; Zeiger auf eigenen Task
  18.     lea    readreply,a1    ; Task herholen
  19.     jsr    -354(a6)    ; ExecCall ADDPORT
  20.     movem.l    (sp)+,d0-d3/a0-a4; Register zurueckholen
  21. ; -----------------------------------------------------------------
  22. ; Filenamen suchen
  23. ; -----------------------------------------------------------------
  24.     lea    $60000,a1    ; String fuer Filename nach a1
  25. search:    move.b    (a0)+,d1    ; Char kopieren
  26.     cmp.b    #$0a,d1        ; Return erreicht ?
  27.     beq.s    found        ; Ja > Gefunden !
  28.     move.b    d1,(a1)+    ; Sonst Char in String kopieren
  29.     bra.s    search        ; Weiter nach Return suchen
  30. found:    move.b    #$0,(a1)+    ; Nullbyte ans Stringende
  31. ; -----------------------------------------------------------------
  32. ; Trackdisk oeffnen und Bootblock reinlesen
  33. ; -----------------------------------------------------------------
  34.     lea    diskio,a1    ; IO-Struktur
  35.     moveq    #0,d0        ; df0:
  36.     moveq    #0,d1        ; keine Flags
  37.     lea    trackdev,a0    ; Trackdisk-Device
  38.     jsr    -444(a6)    ; ExecCall OPENDEVICE
  39.     tst.l    d0        ; Error ?
  40.     bne.L    error        ; Ja, also nichts wie raus hier !
  41.     lea    diskio,a1    ; IO-Struktur
  42.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  43.     move    #14,28(a1)    ; TDComm. CHangestate (Diskette eingelegt?)
  44.     move.l    4,a6        ; Execbase in a6
  45.     jsr    -456(a6)    ; ExecCall DOIO
  46.     lea    diskio,a1    ; IO-Struktur
  47.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  48.     move    #2,28(a1)    ; TDCommand READ
  49.     move.l    #$60080,40(a1)    ; Zeiger auf unseren Buffer
  50.     move.l    #1024,36(a1)    ; 2 Sektoren einlesen
  51.     move.l    #0,44(a1)    ; von Sektor 0 Spur 0
  52.     move.l    4,a6        ; Execbase in a6
  53.     jsr    -456(a6)    ; ExecCall DOIO
  54. ; -----------------------------------------------------------------
  55. ; Device und Tasks schliessen
  56. ; -----------------------------------------------------------------
  57.     lea    diskio,a1    ; IO-Struktur
  58.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  59.     move    #9,28(a1)    ; TDCommand TD-MOTOR
  60.     move.l    #0,36(a1)    ; Motor ausschalten
  61.     jsr    -456(a6)    ; ExecCall DOIO
  62.     lea    readreply,a1    ; Task-Struktur
  63.     jsr    -360(a6)    ; ExecCall REMOVEPORT
  64.     lea    diskio,a1    ; IO-Struktur
  65.     jsr    -450(a6)    ; ExecCall CLOSEDEVICE
  66. ; -----------------------------------------------------------------
  67. ; Mittels AmigaDOS ein File oeffnen und Bootblock abspeichern
  68. ; -----------------------------------------------------------------
  69.     bsr.s    init        ; Doslibrary oeffnen
  70.     move.l    #$60000,d1    ; Zeiger auf den Filenamen
  71.     move.l    #1006,d2    ; Modus : NEU
  72.     jsr    -30(a5)        ; DosCall OPEN
  73.     move.l    d0,a3        ; filehd sichern
  74.     moveq    #10,d3        ; 10 Zeichen
  75.     move.l    #filemsg,d2    ; 'Saving.'-Message
  76.     jsr    -60(a5)        ; DosCall OUTPUT
  77.     jsr    -48(a5)        ; DosCall WRITE
  78.     move.l    a3,d1        ; Zeiger aufs File
  79.     move.l    #$60080,d2    ; Zeiger auf den Bootblock
  80.     move.l    #1024,d3    ; 1024 Zeichen ( = 2 Blocks )
  81.     jsr    -48(a5)        ; DosCall WRITE
  82. ; -----------------------------------------------------------------
  83. ; Alles schliessen und Zurueck ins CLI
  84. ; -----------------------------------------------------------------
  85.     move.l    a3,d1        ; Filehd nach d1
  86.     jsr    -36(a5)        ; DosCall CLOSE
  87. close:    move.l     a5,a1        ; Dosbase zurueckholen
  88.     jsr     -414(a6)    ; Und Schliesen..
  89. error:    rts            ; Zurueck ins CLI
  90. ; -----------------------------------------------------------------
  91. ; Subroutine, die die DOS.library oeffnet
  92. ; -----------------------------------------------------------------
  93. init:    move.l    4,a6        ; Execbase nach a6
  94.     lea    dosname,a1    ; dos.library
  95.     jsr    -408(a6)    ; ExecCall OPENLIBRARY
  96.     move.l    d0,a5        ; Dosbase retten
  97.     rts            ; Zurueck
  98. ; -----------------------------------------------------------------
  99. ; Subroutine, die aufgerufen wird, wenn kein File eingegeben wurde.
  100. ; -----------------------------------------------------------------
  101. nofile:    bsr.s    init        ; Dos.lib oeffnen
  102.     moveq    #10,d3        ; 10 Zeichen
  103.     move.l    #nofilemsg,d2    ; 'Bad Args.'-Message
  104.     jsr    -60(a5)        ; DosCall OUTPUT
  105.     jsr    -48(a5)        ; DosCall WRITE
  106.     bra.s    close        ; Zurueck ins CLI
  107. ; -----------------------------------------------------------------
  108. ; Labels...
  109. ; -----------------------------------------------------------------
  110. dosname: dc.b 'dos.library',0
  111. trackdev: dc.b 'trackdisk.device',0
  112. nofilemsg: dc.b "Bad Args",$a,0
  113. filemsg: dc.b "Saving..",$a,0
  114. even
  115. diskio: blk.l 20,0
  116. readreply: blk.l 8,0
  117.